package com.android.music.fragment;

import com.android.music.R;
import com.android.music.view.ClockSwingView;
import com.android.music.view.PeakValueView;
import com.android.music.view.SpectrumView;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;

public class PlayingFragment extends Fragment implements OnClickListener {

	private View mPlayingFragment;
	private LinearLayout linearLayout;
	private SpectrumView spectrumView;
	private PeakValueView peakValueView;
	public static int which_decibel = 0;

	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		mPlayingFragment = inflater.inflate(R.layout.playing_fragment,
				container, false);
		
		initDecibelMonitor();

		return mPlayingFragment;
	}

	private void initDecibelMonitor() {
		// TODO Auto-generated method stub
		linearLayout = (LinearLayout) mPlayingFragment
				.findViewById(R.id.decibel_monitor_1);
		linearLayout.setOnClickListener(this);

		spectrumView = (SpectrumView) mPlayingFragment
				.findViewById(R.id.decibel_monitor_2);
		spectrumView.setOnClickListener(this);

		peakValueView = (PeakValueView) mPlayingFragment
				.findViewById(R.id.decibel_monitor_3);
		peakValueView.setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub

		switch (arg0.getId()) {
		case R.id.decibel_monitor_1:
			linearLayout.setVisibility(View.GONE);
			spectrumView.setVisibility(View.VISIBLE);
			peakValueView.setVisibility(View.GONE);
			break;
		case R.id.decibel_monitor_2:
			linearLayout.setVisibility(View.GONE);
			spectrumView.setVisibility(View.GONE);
			peakValueView.setVisibility(View.VISIBLE);
		case R.id.decibel_monitor_3:
			linearLayout.setVisibility(View.VISIBLE);
			spectrumView.setVisibility(View.GONE);
			peakValueView.setVisibility(View.GONE);
			break;

		default:
			break;
		}
	}
}